<?php
if (!defined('BASEPATH'))
	exit ('No direct script access allowed');
/**
 * Project: Vietsam
 * Package Controller
 * Class: Tab
 * Author: Khoi Pham		email: pmkhoi@gmail.com
 * Created on Dec 18, 2008
 * Updated on Dec 30, 2008
 *  
 **/
class Home extends MY_Controller {
	function Home() {
		parent::__construct();
		$this->load->model('tab_model', 'tab', true);
		$this->load->helper('form');
		$this->main = '';
		
		$this->load->model('counter_model', 'counter', true);
		//print_r($this->counter->show_counter());
		$this->checkLogin();
                $this->buildMenu();
		//$this->checkPermission();
               // print_r( $this->session->userdata('user'));
                //$this->template->write('fullname', $this->session->user_data('user')->);
                //$this->template->set_template('admin');
	}
	
	function index() { //echo time();
		/*$error_message = '';
		$this->setTemplate(array('tabs_list.tpl'));
		$this->main = eval($this->loadTemplate('tabs_list.tpl'));
		$this->execute();*/
		$this->view();
	}
			
	function view(){
		$NUMBER_RECORD_PER_PAGE = 15;
		$this->load->library('pagination');
		$parent = $this->uri->segment(4, 0);
		$page = (int)$this->uri->segment(5);
		$config['base_url'] = base_url() . 'admin/tab/view/' . $parent;
		$config['total_rows'] = $this->tab->getAllCount($parent);
		$config['per_page'] = $NUMBER_RECORD_PER_PAGE;
		$config['uri_segment'] = 5;
		$config['first_link'] = 'First';
		
		$this->pagination->initialize($config);
						
		$rows = $this->tab->getAll($parent, $page, $NUMBER_RECORD_PER_PAGE);
		
		$data = array();
		$data['rows'] = $rows;
		//$this->main = $this->load->view('admin/home/home', $data, true);
		
		$this->template->parse_view('content', 'admin/home/home',$data);
                $this->template->render();
	}
	
	
}
?>
